package de.baumann.browser.present

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.WalletApiService
import de.baumann.browser.api.net.base.ApiBuilder
import de.baumann.browser.api.net.vo.HashValue
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IHashValueView
import de.baumann.browser.rx.RxSchedulers

class HashValuePresenter : BasePresenter<IHashValueView>() {
    private val walletService: WalletApiService = ApiBuilder.buildService(WalletApiService::class.java)
    fun getHashRecord() {
        walletService.getPowerRecord(view!!.getAddress())
                .compose(RxSchedulers.ioMain())
                .subscribe(object : OdinObserver<List<HashValue>>() {
                    override fun onSuccess(data: List<HashValue>?) {
                        if (view !=null && data!=null){
                            view.setHashValues(data)
                        }
                    }
                })
    }
}